﻿namespace DreamBuilder.Common
{
    using DreamBuilder.Core.DAO;
    using System;
    using System.Data;

    public static class AttachmentHelper
    {
        public static void AddAttachmentsDataTable(DataSet ds, string mainTableCode, string PKValue)
        {
            IDBHelper helper = DBHelperFactory.CreateInstance("business");
            DataTable table = null;
            string strSql = "select P_BT_Attachments.*,'3' as RowStatus from P_BT_Attachments where ObjectTableName = '" + mainTableCode + "' and ObjectID = '" + PKValue + "'";
            table = helper.ExecuteDataSet(strSql).Tables[0];
            table.PrimaryKey = new DataColumn[] { table.Columns["AttachmentID"] };
            table.TableName = "P_BT_Attachments";
            ds.Tables.Add(table.Copy());
        }
    }
}

